package com.beetlestech.nfe.main.biz.com.impl;

import java.util.List;
import com.beetlestech.nfe.fw.core.biz.AbstractDBLogic;
import com.beetlestech.nfe.main.biz.com.HbStanding;
import com.beetlestech.nfe.main.biz.constant.CommonConstant;
import com.beetlestech.nfe.main.biz.constant.CtgCodeConstant;
import com.beetlestech.nfe.main.biz.constant.HbMessageCode;
import com.beetlestech.nfe.main.db.constant.SQLConstant;
import com.beetlestech.nfe.main.db.tbl.MstusrDTO;
import com.beetlestech.nfe.main.db.tbl.UsermessageDTO;


public class HbStandingImpl extends AbstractDBLogic implements HbStanding, CtgCodeConstant, HbMessageCode, CommonConstant, SQLConstant {
	
	
	//像全体学员发送站内信
	@Override
	public void saveAllMsg(String title,String content){
		//查询所有学员
		MstusrDTO mu=new MstusrDTO();
		mu.settype(0);
		List<MstusrDTO> list=queryDAO.queryForObjectList(MstusrDTO.EQUAL_SEARCH,mu);
		for(int i=0;i<list.size();i++){
			createMessage(title,content,list.get(i).getusrid());
		}
	}
	//创建消息
	private void createMessage(String title,String content,Integer sid){
		
		UsermessageDTO userMessage = new UsermessageDTO();
		userMessage.setTitel(title);
		userMessage.setMessage(content);
		userMessage.setSenderId(SERVER_ID);
		userMessage.setReceiveId(sid);
		userMessage.setSendDT(getCurrentDate());
		userMessage.setSendTime(getCurrentTime());
		userMessage.setReadflg(Integer.parseInt(CATAGORY_P_MESSAGE_STATE.UNREAD.toString()));
		updateDAO.update(UsermessageDTO.INSERT, userMessage);
	}

	
	
	
}
